import AppBar from "@/components/layouts/AppBar"; import Layout from "@/components/layouts/Layout"; import LineDivider from "@/components/elements/LineDivider"; import WithAuth from "@/components/auth/WithAuth"; import { useEffect, useState } from "react"; import apiOdoo from "@/core/utils/apiOdoo"; import { useRouter } from "next/router"; import { useAuth } from "@/core/utils/auth"; import VariantCard from "@/components/variants/VariantCard"; import currencyFormat from "@/core/utils/currencyFormat"; import Disclosure from "@/components/elements/Disclosure"; import DescriptionRow from "@/components/elements/DescriptionRow"; import { SkeletonList } from "@/components/elements/Skeleton"; export default function DetailInvoice() { const router = useRouter(); const { id } = router.query; const [ auth ] = useAuth(); const [ invoice, setInvoice ] = useState(null); useEffect(() => { if (auth && id) { const loadInvoice = async () => { const dataInvoice = await apiOdoo('GET', `/api/v1/partner/${auth?.partner_id}/invoice/${id}`); setInvoice(dataInvoice); } loadInvoice(); } }, [ auth, id ]); const Customer = () => { const customer = invoice?.customer; const fullAddress = []; if (customer?.street) fullAddress.push(customer.street); if (customer?.sub_district?.name) fullAddress.push(customer.sub_district.name); if (customer?.district?.name) fullAddress.push(customer.district.name); if (customer?.city?.name) fullAddress.push(customer.city.name); return (
{ invoice?.customer?.name } { invoice?.customer?.email || '-' } { invoice?.customer?.mobile || '-' } { fullAddress.join(', ') }
); }; const downloadTaxInvoice = () => { window.open(`${process.env.ODOO_HOST}/api/v1/download/tax-invoice/${invoice.id}/${invoice.token}`, 'Download') } const downloadInvoice = () => { window.open(`${process.env.ODOO_HOST}/api/v1/download/invoice/${invoice.id}/${invoice.token}`, 'Download') } return ( { invoice ? ( <>
{ invoice?.name } { invoice?.amount_residual > 0 ? ( Belum Lunas ) : ( Lunas ) } { invoice?.purchase_order_name || '-' } { invoice?.payment_term } { invoice?.amount_residual > 0 && invoice.invoice_date != invoice.invoice_date_due && ( { invoice?.invoice_date_due } ) } { invoice?.sales } { invoice?.invoice_date }

Faktur Pembelian

Faktur Pajak

{ invoice?.products?.map((product, index) => ( )) }

Total Belanja

{ currencyFormat(invoice?.amount_total || 0) }

) : (
) }
); }